<?php

header("content-type:text/html;charset=utf-8");
// 导入配置文件
require "./configs/config.php";

// 导入model类和控制器
// require "./models/Model.class.php";
// require "./controllers/indexController.class.php";
// require "./controllers/userController.class.php";
// require "./controllers/goodsController.class.php";


// 自动加载类
function mvc_autoload($classname){
	if(file_exists("./models/{$classname}.class.php")){
		require "./models/{$classname}.class.php";
	}else if(file_exists("./controllers/{$classname}.class.php")){
		require "./controllers/{$classname}.class.php";
	}else{
		header("http/1.0 404 not find");//非ie设置状态码
		header("status:404 not find");//ie设置状态码
		echo "<h1>404 NOT FIND</h1>";
		die();
	}
}

// 导入smarty模板
require "./libs/smarty.class.php";

// spl_autoload_register :注册给定函数作为__autoload()的实现;即使给定的参数函数具有和__autoload()一样的功能
spl_autoload_register("mvc_autoload");


$c=(!empty($_GET['c']))?$_GET['c']:'Index';
$a=(!empty($_GET['a']))?$_GET['a']:'index';

$classname=$c.'Controller';

$controller=new $classname();

$data=$controller->$a();